/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.farmcode.server.config;

import com.farmcode.api.util.FARMCodeAPI;
import java.io.File;
import java.io.IOException;
import java.util.Properties;

/**
 *
 * @author Oscar Ivan Prado
 */
public class InitialContext {

    private static Properties properties;

    public static Properties configure() throws IOException {
        String home = System.getProperty("com.farmcode.server.home");
        String config = System.getProperty("com.farmcode.server.config");
        return configure(home, config);
    }

    public static Properties configure(String home, String configPath) throws IOException {
        if (properties == null) {
            File file = new File(home + File.separatorChar + configPath + File.separatorChar + "config.properties");
            properties = FARMCodeAPI.getProperties(file);
            properties.put("com.farmcode.server.home", home);
            properties.put("com.farmcode.server.config", configPath);
        }
        return properties;
    }
    
}
